package Chapter17.method_;

/**
 * @author 杨森
 * @date 2022年10月31日 19:16
 */
public class ThreadMethodExercise {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new T3());
        for (int i = 1; i <=10; i++) {
            System.out.println("hi" + i);
            if (i == 5) {
                thread.start();
                thread.join();
            }
        }
    }
}

class T3 implements Runnable {
    private int count = 0;

    @Override
    public void run() {
        while (true) {
            System.out.println("hello" + (++count));

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if (count == 10) {
                break;
            }
        }
    }
}
